package kit.edu.lego.gruppe3.levels.sumpf;

import kit.edu.lego.gruppe3.ComponentsRepository;
import kit.edu.lego.gruppe3.levels.LevelSelector;
import lejos.nxt.LightSensor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.subsumption.Behavior;

public class LightGround implements Behavior
{

	private LightSensor lightS = ComponentsRepository.getInstance().getLightSensor();
	private DifferentialPilot robot = ComponentsRepository.getInstance().getRobotPilot();
	
	@Override
	public void action()
	{
		if (SumpfLineCrossed.getInstance().lastCrossingWasDark())
		{
			SumpfLineCrossed.getInstance().crossLightArea();
		}
		
		robot.setTravelSpeed(6);
		robot.steer(-3);
//		robot.forward();
		

	}

	@Override
	public void suppress()
	{
	
	}

	@Override
	public boolean takeControl() 
	{
		return LevelSelector.getInstance().isSumpf() &&
			lightS.getLightValue() > ComponentsRepository.LIGHT_TRASHOLD;
	}
}
